/**
 * Make a ASCII Table in a div (divName)
 * in decimal interval between initDec and endDec 
 */
function initAscii(divName, initDec, endDec, caption ){
    var x = "";
    x = x + "<table align='center' border='1' width='100%'>";
    x = x + "<caption>" + caption + "</caption>";
    x = x + "<tr style='text-align:right;'>";
    x = x + "<td title='Decimal'>Dec</td>";
    x = x + "<td title='Hexadecimal'>Hex</td>";    
    x = x + "<td title='Binary'>Bin</td>";    
    x = x + "<td title='Octal'>Oct</td>";    
    x = x + "<td>Html</td>";    
    x = x + "<td>Char</td>";    
    x = x + "</tr>"; 
    for(i = initDec; i <= endDec; i++){
        c = String.fromCharCode(i);
        x = x + "<tr style='text-align:right;'>";
        x = x + "<td>" + i + "</td>";    
        //x = x + "<td>" + escape(c) + "</td>"; 
        x = x + "<td>" + i.toString(16).toUpperCase() + "</td>";
        x = x + "<td>" + i.toString(2) + "</td>";    
        //x = x + "<td>" + upperTrim( i.toString(16)) + "</td>"   
        x = x + "<td>" + i.toString(8) + "</td>";    
        x = x + "<td>" + "&amp;#" + i + ";" + "</td>";    
        x = x + "<td>" + c + "</td>";    
        x = x + "</tr>";
    }
    x = x + "</table>";
    var div = document.getElementById(divName); 
    div.innerHTML = x;  
return "";
}

function initAsciiFromHex(divName, initHex, endHex ){
    var caption = "Range: " + initHex + " - " + endHex;
	return initAscii(divName, h2d(initHex), h2d(endHex),caption);
}

function d2h(d) {return d.toString(16);}
function h2d(h) {return parseInt(h,16);}
